import socket

# 配置参数
LOCAL_HOST = '127.0.0.1'
PORT = 5000
BUFFER_SIZE = 4096


s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((LOCAL_HOST, PORT))

while True:
    MESSAGE = input('>> ')
    s.sendall(MESSAGE.encode('utf-8'))
    recv = s.recv(BUFFER_SIZE).decode('utf-8')
    print(f'recv from server: {recv}')